﻿using System;
using System.Net;

namespace OpenICEcatConnector.Utils
{
    public class FileDownloader
    {
        public static Byte[] DownloadICEcatFile(String strDownloadUrl, String user, String password)
        {
            // Creating an instance of a WebClient
            WebClient req = new WebClient();

            // Creating an instance of a credential cache,
            // and passing the username and password to it.
            CredentialCache cache = new CredentialCache();
            cache.Add(new Uri(strDownloadUrl), "Basic", new NetworkCredential(user, password));
            req.Credentials = cache;

            Byte[] fileData = req.DownloadData(strDownloadUrl);
            return fileData;
        }
    }
}
